home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
xmessage
/
readfile.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-22
|
1KB
|
51 lines
/*
* xmessage - utility for querying users
*
* Copyright 1988,1991 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include <X11/Xos.h> /* for types.h */
#include <sys/stat.h>
#include <stdio.h>
extern char *malloc();
static char filename[80];
/*
* copy_stdin - copy stdin to a temporary file and return the name of the
* temporary file.
*/
char *copy_stdin ()
{
char buf[BUFSIZ];
int mfile;
int n;
char *cp;
strcpy (filename, "/tmp/xmessage-XXXXXX");
mktemp (filename);
if (!filename[0])
return NULL;
mfile = creat(filename, 0600);
if (mfile < 0) return NULL;
while ((n = fread (buf, 1, BUFSIZ, stdin)) > 0) {
(void) write (mfile, buf, n);
}
(void) close (mfile);
return filename;
}